#include<vector>
#include<iostream>
using std::vector;


class Solution {
public:
    vector<int> searchRange(vector<int>& nums, int target) {
        // 转换为找到第一个</> target 的元素的索引
        // 如果两个索引相邻，则没有target

        // 特殊情况
        if (nums.size() == 0 || target > nums[nums.size()-1] || target < nums[0]) return {-1, -1};

        int pos0 = this->find1stLess(nums, target);
        int pos1 = this->find1stLarge(nums, target);
        if (pos0 + 1 == pos1) return {-1, -1};
        else return {pos0+1, pos1-1};
    }

    int find1stLess(vector<int>& nums, int target) {
        int left = 0, right = nums.size();
        while (left < right) {
            auto mid = (left + right) / 2;
            if (nums[mid] < target && ((mid + 1 < right && nums[mid+1] >= target) || (mid+1 == right))) {
                return mid;
            }
            else if (nums[mid] < target) left = mid;
            else right = mid;
        }
        return -1;
    }

    int find1stLarge(vector<int>& nums, int target) {
        int left = 0, right = nums.size();
        
        while (left < right) {
            //std::cout << "(" << left << "," << right << ")" << "\n";
            auto mid = (left + right) / 2;
            if (nums[mid] > target && ((mid - 1 >= left && nums[mid-1] <= target) ||  mid-1 < left)) {
                return mid;
            }
            else if (nums[mid] <= target) left = mid+1;
            else right = mid;
        }
        return nums.size();
    }
};

int main() {
    vector<int> input = {};
    int n;
    while (std::cin >> n) {
        input.push_back(n);
    }
    std::cout << "input: \n";
    for (auto k: input) std::cout << k << " ";
    std::cout << "\n";
    

    auto res = Solution().searchRange(input, 0);
    std::cout << res[0] << ", " << res[1] << "\n";
    return 0;
}